<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="Cache-Control"  content="no-transform">
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>购物车</title>
    <link href="/statics/view/css/shop_common.css" rel="stylesheet" type="text/css" />
    <link href="/statics/view/css/shop_layout.css" rel="stylesheet" type="text/css" />
    <style type="text/css"> </style>
</head>
<body>
<script src="//ms2-m.vipstatic.com/js/lib/a478accf5e.jquery-2.1.0.min.js"></script>
<script src="/statics/view/js/shop.js"></script>
<header id="header" class="u-header clearfix">
    <div class="u-hd-left f-left">
        <a href="javascript:void(0)" mars_sead="cart-back_btn" class="J_backToPrev"><span class="u-icon-px i-hd-back"></span></a>
    </div>
    <span class="u-hd-tit">购物车</span>
    <div class="u-hd-right f-right"><a href="cart-history.html" mars_sead="check-shopping-history_btn"><span class="u-icon-px i-hd-history"></span></a></div>
</header>
<style type="text/css">body{background-color: #f3f4f5;}.u-footer{display:none;}</style>
<div class="ui-page ui-page-shopping-cart" id="J-shopping-cart">
    <div class="ui-page-content">
    [#if cart?? && cart.shopCarts?has_content]
        [#list cart.shopCarts as shopCart]
      <div class="section section-cart-order ui-list">
            <div class="ui-list-header-item ui-border-b">
               <h2 class="single-line">${shopCart.shopName} </h2>
            </div>
           <ul class="border-dash">
               [#list shopCart.cartItems as cartItem]
               <li class="ui-list-item">
                   <div class="ui-list-item-inner">
                       <a href="" class="ui-list-item-thumb">
                           <img src="[#if cartItem.product.thumbnail??]${cartItem.product.thumbnail}[/#if]" alt="" data-brandlazy="true" style="display: inline;">
                       </a>
                       <div class="ui-list-item-info">
                           <a href="product-570343-76189039.html?rbc=url_cart" class="meta">
                               <h4 class="title">${cartItem.product.name}</h4>
                               <p class="single-line">
                                   <span>${cartItem.product.name}</span>
                               </p>
                               <p></p>
                           </a>
                           <div class="stock clearfix" data-product_id="${cartItem.product.id}" data-size_id="">
                               <a href="javascript:;" class="ui-button ui-button-border ui-button-border-gray ui-button-border-small" data-action="moveNum" cart-item-id="${cartItem.id}" product-num="${cartItem.quantity}" mars_sead="cart_edit_btn" data_mars="prd_id:76189039">
                                   <i class="iconfont iconfont-move"></i>
                               </a>
                               <span>${cartItem.quantity}</span>
                               <input class="amount-num" type="text" readonly="readonly" data-brand-id="570343" data-product_id="76189039" data-size_id="196097105" data-id="" value="${cartItem.quantity}" name="num">
                               <a href="javascript:;"  class="ui-button ui-button-border ui-button-border-gray ui-button-border-small" data-action="addNum" cart-item-id="${cartItem.id}" product-num="${cartItem.quantity}"  mars_sead="cart_edit_btn" data_mars="prd_id:76189039">
                                   <i class="iconfont iconfont-add"></i>
                               </a>
                               <a href="javascript:;" class="close" data-action="delete" data-usecoupon="0"  cart-item-id="${cartItem.id}" product-num="${cartItem.quantity}"   mars_sead="cart_delect_btn" data_mars="prd_id:76189039">
                                   <i class="iconfont iconfont-close"></i>
                               </a>
                           </div>
                           <a href="product-570343-76189039.html?rbc=url_cart" class="price">
                               <span class="original-price">￥${cartItem.product.price}</span>
                               <del>￥${cartItem.product.marketPrice}</del>
                           </a>
                       </div>
                   </div>
               </li>
               [/#list]
        </ul>
        <div class="section-footer">
            <div class="total-price clearfix">
                <span class="c_price"> ¥${shopCart.price} </span>
            </div>
        </div>
    </div>
        [/#list]
    [/#if]
    </div>
    <div class="settle-accounts ui-border-t fixed-bottom">
        <div class="total-price">
            总金额<strong> ¥${cart.price}</strong>
        </div>
        <a href="/shop/cart/checkout" class="ui-button ui-button-primary" mars_sead="first-check_btn" data-islogin="true" data-shopcarthide="true" data-countdown="true" data-carttime="1199" data-toggle="modal">
            结算
            <div class="countdown"><span>18</span><span>:</span><span>55</span><span></span></div>
        </a>
    </div>
</div>
<a href="#top" class="u-backtop" mars_sead="home_foot_top_btn">
    <span class="u-icon-px i-backtop"></span>
</a>
<script type="text/javascript" src="/statics/layer.m/layer.m.js"></script>
<script type="text/javascript">
    $(function(){
        $("a[data-action='moveNum']").click(function(){
            var cartItemId=$(this).attr("cart-item-id");
            var num=$(this).attr("product-num");
            editCartItem(cartItemId,parseInt(num)-1);
        });
        $("a[data-action='addNum']").click(function(){
            var cartItemId=$(this).attr("cart-item-id");
            var num=$(this).attr("product-num");
            editCartItem(cartItemId,parseInt(num)+1);
        });
        $("a[data-action='delete']").click(function(){
            var cartItemId=$(this).attr("cart-item-id");
            delCartItem(cartItemId);
        });
    });

    /* 修改购物车产品数量*/
    function editCartItem(cartItemId,quantity){
        $.ajax({
            type:  'POST',
            url:"/shop/cart/edit",
            data:{id:cartItemId,quantity:quantity},
            dataType:"json",
            cache: false,
            success: function(data){
                if(data.message.type=='success'){
                    layer.open({
                        content: data.message.content,
                        time: 1
                    });
                    window.location.reload();
                }else{
                    layer.open({
                        content: data.message.content,
                        time: 1
                    });
                }
            }
        });
    }

    /* 修改购物车产品数量*/
    function delCartItem(cartItemId){
        $.ajax({
            type:  'POST',
            url:"/shop/cart/delete",
            data:{id:cartItemId},
            dataType:"json",
            cache: false,
            success: function(data){
                if(data.message.type=='success'){
                    layer.open({
                        content: data.message.content,
                        time: 1
                    });
                    window.location.reload();
                }else{
                    layer.open({
                        content: data.message.content,
                        time: 1
                    });
                }
            }
        });
    }
</script>
</body>
</html>